/*
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.lefeng.cockpit.resource.storage;

import com.lefeng.cockpit.common.enums.resource.ResourceType;

import java.io.IOException;
import java.util.List;

public interface StorageOperate {


    /**
     * create the directory that the path of tenant wanted to create
     *
     * @param path path
     * @return ..
     * @throws IOException IOException
     */
    boolean mkdir(String path) throws IOException;


    /**
     * get the path of the file
     *
     * @param resourceType resourceType
     * @param fileName     fileName
     * @return ..
     */
    String getFileName(ResourceType resourceType, String fileName);

    /**
     * predicate  if the resource of tenant exists
     *
     * @param fileName fileName
     * @return ..
     * @throws IOException IOException
     */
    boolean exists(String fileName) throws IOException;

    /**
     * if the resource of tenant 's exist, the resource of folder will be created
     *
     * @throws Exception Exception
     */
    void createTenantDirIfNotExists() throws IOException;

    /**
     * get the root path of the tenant with resourceType
     *
     * @param resourceType resourceType
     * @return ..
     */
    String getDir(ResourceType resourceType);

    /**
     * upload the local srcFile to dstPath
     *
     * @param srcFile      srcFile
     * @param dstPath      dstPath
     * @param deleteSource deleteSource
     * @param overwrite    overwrite
     * @return bb
     * @throws IOException IOException
     */
    boolean upload(String srcFile, String dstPath, boolean deleteSource, boolean overwrite) throws IOException;

    /**
     * delete the resource of  filePath
     * todo if the filePath is the type of directory ,the files in the filePath need to be deleted at all
     *
     * @param filePath  filePath
     * @param recursive recursive
     * @return
     * @throws IOException IOException
     */
    boolean delete(String filePath, boolean recursive) throws IOException;

    /**
     * get the resource directory of tenant
     *
     * @return gg
     */
    String getResDir();

    /**
     * get the path of the resource file
     *
     * @param fullName fullName
     * @return gg
     */
    String getResourceFileName(String fullName);

    /**
     * vim the context of filePath
     * @param filePath filePath
     * @param skipLineNums skipLineNums
     * @param limit limit
     * @return ,..
     * @throws IOException ..
     */
    List<String> vimFile(String filePath, int skipLineNums, int limit) throws IOException;
}
